package org.elsfs.auth.service;

import java.util.Collection;
import lombok.Getter;
import lombok.Setter;
import org.elsfs.domain.entity.SysUser;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

/**
 * 适配security
 *
 * @author zeng
 * @since 0.0.1
 */
@Getter
@Setter
public class UserDetailsImpl extends User {

  private Collection<GrantedAuthority> authorities;
  private String password;
  private String username;

  /**
   * 构造器
   *
   * @param sysUser sysUser
   * @param authorities authorities
   */
  public UserDetailsImpl(SysUser sysUser, Collection<GrantedAuthority> authorities) {
    super(sysUser.getUsername(), sysUser.getPassword(), authorities);
    this.authorities = authorities;
    this.username = sysUser.getUsername();
    this.password = sysUser.getPassword();
  }

  @Override
  public Collection<GrantedAuthority> getAuthorities() {
    return authorities;
  }
}
